<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>核酸检测登记记录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <script src="../element-ui/lib/index.js"></script>
    <link rel="stylesheet" href="../element-ui/lib/theme-chalk/index.css">
</head>
<body>
<div id="div">
    <b style="color: red; font-size: 20px;">核酸检测登记记录</b>
    <el-table :data="tableData">
        <el-table-column align="center" type=index label="序号" prop="testId" width="100px"></el-table-column>
        <el-table-column align="center" prop="time" label="检测时间"></el-table-column>
        <el-table-column align="center" prop="userNumber" label="学号/工号"></el-table-column>
        <el-table-column align="center" prop="userInfo.name" label="姓名"></el-table-column>
        <el-table-column align="center" prop="userInfo.identification" label="身份证号码"></el-table-column>
        <el-table-column align="center" prop="result" label="结果（1阴性；2阳性）"></el-table-column>
    </el-table>
</div>

<script>
    new Vue({
        el: "#div",
        data: {
            tableData:[],
            user: {},
            userInfo: {}
        },
        methods: {
            //分页查询功能
            selectByPage() {
                //向后台发送请求
                let param = "action=toShowAcid&userNumber=" + this.user.userNumber;
                console.log(param)
                axios.post("/EpidemicControlSystem_war_exploded/NucleicAcidServlet", param)
                    .then(response => {
                        //将查询出的数据赋值给tableData
                        console.log(response.data)
                        this.tableData = response.data.nucleicAcids;
                    });
            },

            getUser() {
                axios.post("/EpidemicControlSystem_war_exploded/UserServlet", "action=user")
                    .then(res => {
                        this.user = res.data.loginUser;
                        this.userInfo = res.data.loginUserInfo;
                        //调用分页查询功能
                        this.selectByPage();
                    });
            }
        },
        created() {
            this.getUser();
        }
    });
</script>
</body>
</html>